package com.teamwork_backend.mapper;

import com.teamwork_backend.entity.CompanyInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teamwork_backend.entity.ov.CompanysListView;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author windy
 * @since 2021-04-25
 */
public interface CompanyInfoDao extends BaseMapper<CompanyInfo> {
    // 这里就是自定义的SQL语句实现联表查询
    // 两个表之间关联操作
    @Select("SELECT * FROM company_info WHERE company_info.companyid IN (SELECT companyid FROM companys WHERE account = #{account})")
    CompanyInfo getCompanyInfoByAccount(@Param("account") String account);

    @Select("SELECT companys.companyid,account,name,logo,website,registerdate,address,phone,intro residence FROM companys LEFT JOIN `company_info` on companys.companyid = company_info.companyid WHERE type = 0 AND (account LIKE CONCAT('%',#{content},'%') OR name LIKE CONCAT('%',#{content},'%'))")
    List<CompanysListView> searchCompanyInfo(@Param("content") String content);
}
